1pub struct Section {
2 beg: u8,
3 end: u8,
4}
5
6impl std::fmt::Debug for Section {
7 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
8 f.debug_tuple("Section")
9 .field(&self.beg)
10 .field(&self.end)
11 .finish()
12 }
13}
14
15impl Section {
16 pub const fn new(beg: u8, end: u8) -> Self {
17 Section { beg, end }
18 }
19
20 pub fn its(&self, key: u8) -> bool {
21 return (!(self.beg == self.end && self.beg == 0xFF))
22 && (key >= self.beg && key <= self.end);
23 }
24}
25
26#[derive(Debug)]
27pub struct ScriptInfo {
28 pub name: &'static str,
29 pub version: u16,
30 pub uint8x2: Section,
32 pub uint8str: Section,
34 pub string: Section,
36 pub encstr: Section,
38 pub uint16x4: Section,
40 pub optunenc: u8,
42 pub deckey: u8,
43 pub nameopcode: u8,
44}
45
46const SCRIPT_INFO: [ScriptInfo; 31] = [
47 ScriptInfo::new(
48 "ffexa",
49 0x7B69,
50 (0x00, 0x28),
51 (0x29, 0x2E),
52 (0x2F, 0x49),
53 (0x4A, 0x4D),
54 (0x4E, 0xFF),
55 0x43,
56 0x20,
57 0x4B,
58 ),
59 ScriptInfo::new(
60 "ffexs",
61 0x7B6B,
62 (0x00, 0x28),
63 (0x29, 0x2E),
64 (0x2F, 0x4B),
65 (0x4c, 0x4F),
66 (0x50, 0xFF),
67 0x43,
68 0x20,
69 0x4D,
70 ),
71 ScriptInfo::new(
72 "ef",
73 0x466A,
74 (0x00, 0x28),
75 (0x2A, 0x2F),
76 (0x30, 0x4A),
77 (0x4B, 0x4E),
78 (0x4F, 0xFF),
79 0x46,
80 0x20,
81 0x4C,
82 ),
83 ScriptInfo::new(
84 "dcos",
85 0x315D,
86 (0x00, 0x2B),
87 (0xFF, 0xFF),
88 (0x2C, 0x45),
89 (0x46, 0x49),
90 (0x4A, 0xFF),
91 0x42,
92 0x20,
93 0x47,
94 ),
95 ScriptInfo::new(
96 "ktlep",
97 0x6E69,
98 (0x00, 0x28),
99 (0x29, 0x2E),
100 (0x2F, 0x49),
101 (0x4A, 0x4D),
102 (0x4E, 0xFF),
103 0x45,
104 0x20,
105 0x4B,
106 ),
107 ScriptInfo::new(
108 "dcws",
109 0x656C,
110 (0x00, 0x2B),
111 (0x2C, 0x31),
112 (0x32, 0x4C),
113 (0x4D, 0x50),
114 (0x51, 0xFF),
115 0x48,
116 0x20,
117 0x4E,
118 ),
119 ScriptInfo::new(
120 "dcsv",
121 0x636C,
122 (0x00, 0x2B),
123 (0x2C, 0x31),
124 (0x32, 0x4C),
125 (0x4D, 0x50),
126 (0x51, 0xFF),
127 0x46,
128 0x20,
129 0x4E,
130 ),
131 ScriptInfo::new(
132 "dcpc",
133 0x3D63,
134 (0x00, 0x2C),
135 (0xFF, 0xFF),
136 (0x2D, 0x49),
137 (0x4A, 0x4D),
138 (0x4E, 0xFF),
139 0x44,
140 0x20,
141 0x4B,
142 ),
143 ScriptInfo::new(
144 "dcmems",
145 0x315D,
146 (0x00, 0x2B),
147 (0xFF, 0xFF),
148 (0x2C, 0x45),
149 (0x46, 0x49),
150 (0x4A, 0xFF),
151 0x42,
152 0x20,
153 0x47,
154 ),
155 ScriptInfo::new(
156 "dcdx",
157 0x7769,
158 (0x00, 0x28),
159 (0x29, 0x2E),
160 (0x2F, 0x49),
161 (0x4A, 0x4D),
162 (0x4E, 0xFF),
163 0x45,
164 0x20,
165 0x4B,
166 ),
167 ScriptInfo::new(
168 "dcas",
169 0x4E69,
170 (0x00, 0x28),
171 (0x29, 0x2E),
172 (0x2F, 0x49),
173 (0x4A, 0x4D),
174 (0x4E, 0xFF),
175 0x43,
176 0x20,
177 0x4B,
178 ),
179 ScriptInfo::new(
180 "dcbs",
181 0x3163,
182 (0x00, 0x2B),
183 (0xFF, 0xFF),
184 (0x2C, 0x48),
185 (0x49, 0x4C),
186 (0x4D, 0xFF),
187 0xFF,
188 0x20,
189 0x4A,
190 ),
191 ScriptInfo::new(
192 "dc2fl",
193 0x9C69,
194 (0x00, 0x28),
195 (0x29, 0x2E),
196 (0x2F, 0x49),
197 (0x4A, 0x4D),
198 (0x4E, 0xFF),
199 0x45,
200 0x20,
201 0x4B,
202 ),
203 ScriptInfo::new(
204 "dc2bs",
205 0x316C,
206 (0x00, 0x2B),
207 (0x2C, 0x31),
208 (0x32, 0x4C),
209 (0x4D, 0x50),
210 (0x51, 0xFF),
211 0xFF,
212 0x20,
213 0x4E,
214 ),
215 ScriptInfo::new(
216 "dc2dm",
217 0x9D72,
218 (0x00, 0x29),
219 (0x2A, 0x31),
220 (0x32, 0x4C),
221 (0x4D, 0x50),
222 (0x51, 0xFF),
223 0x44,
224 0x20,
225 0x4E,
226 ),
227 ScriptInfo::new(
228 "dc2fy",
229 0x3866,
230 (0x00, 0x2E),
231 (0xFF, 0xFF),
232 (0x2F, 0x4B),
233 (0x4C, 0x4F),
234 (0x50, 0xFF),
235 0x48,
236 0x20,
237 0x4D,
238 ),
239 ScriptInfo::new(
240 "dc2cckko",
241 0x026C,
242 (0x00, 0x2B),
243 (0x2C, 0x31),
244 (0x32, 0x4C),
245 (0x4D, 0x50),
246 (0x51, 0xFF),
247 0xFF,
248 0x20,
249 0x4E,
250 ),
251 ScriptInfo::new(
252 "dc2ccotm",
253 0x016C,
254 (0x00, 0x2B),
255 (0x2C, 0x31),
256 (0x32, 0x4C),
257 (0x4D, 0x50),
258 (0x51, 0xFF),
259 0xFF,
260 0x20,
261 0x4E,
262 ),
263 ScriptInfo::new(
264 "dc2sc",
265 0x3B69,
266 (0x00, 0x28),
267 (0x29, 0x2E),
268 (0x2F, 0x49),
269 (0x4A, 0x4D),
270 (0x4E, 0xFF),
271 0x45,
272 0x20,
273 0x4B,
274 ),
275 ScriptInfo::new(
276 "dc2ty",
277 0x5F69,
278 (0x00, 0x28),
279 (0x29, 0x2E),
280 (0x2F, 0x49),
281 (0x4A, 0x4D),
282 (0x4E, 0xFF),
283 0xFF,
284 0x20,
285 0x4B,
286 ),
287 ScriptInfo::new(
288 "dc2pc",
289 0x5769,
290 (0x00, 0x28),
291 (0x29, 0x2E),
292 (0x2F, 0x49),
293 (0x4A, 0x4D),
294 (0x4E, 0xFF),
295 0x45,
296 0x20,
297 0x4B,
298 ),
299 ScriptInfo::new(
300 "dc3rx",
301 0x9772,
302 (0x00, 0x2B),
303 (0x2C, 0x33),
304 (0x34, 0x4E),
305 (0x4F, 0x52),
306 (0x53, 0xFF),
307 0x45,
308 0x20,
309 0x50,
310 ),
311 ScriptInfo::new(
312 "dc3pp",
313 0x9872,
314 (0x00, 0x2A),
315 (0x2B, 0x32),
316 (0x33, 0x4E),
317 (0x4F, 0x51),
318 (0x52, 0xFF),
319 0x45,
320 0x20,
321 0x50,
322 ),
323 ScriptInfo::new(
324 "dc3wy",
325 0xA09F,
326 (0x00, 0x38),
327 (0x39, 0x41),
328 (0x42, 0x5F),
329 (0x60, 0x63),
330 (0x64, 0xFF),
331 0x55,
332 0x20,
333 0x61,
334 ),
335 ScriptInfo::new(
336 "dc3dd",
337 0xA5A8,
338 (0x00, 0x38),
339 (0x39, 0x43),
340 (0x44, 0x62),
341 (0x63, 0x67),
342 (0x68, 0xFF),
343 0x58,
344 0x20,
345 0x64,
346 ),
347 ScriptInfo::new(
348 "dc4",
349 0xAAB6,
350 (0x00, 0x3A),
351 (0x3B, 0x47),
352 (0x48, 0x68),
353 (0x69, 0x6D),
354 (0x6E, 0xFF),
355 0x5D,
356 0x20,
357 0x6A,
358 ),
359 ScriptInfo::new(
360 "dc4ph",
361 0xABB6,
362 (0x00, 0x3A),
363 (0x3B, 0x47),
364 (0x48, 0x68),
365 (0x69, 0x6D),
366 (0x6E, 0xFF),
367 0x5D,
368 0x20,
369 0x6A,
370 ),
371 ScriptInfo::new(
372 "ds",
373 0x9F9A,
374 (0x00, 0x38),
375 (0x39, 0x4A),
376 (0x41, 0x5E),
377 (0x5F, 0x62),
378 (0x63, 0xFF),
379 0x54,
380 0x20,
381 0x60,
382 ),
383 ScriptInfo::new(
384 "dsif",
385 0xA1A1,
386 (0x00, 0x39),
387 (0x3A, 0x42),
388 (0x43, 0x60),
389 (0x61, 0x64),
390 (0x65, 0xFF),
391 0x56,
392 0x20,
393 0x62,
394 ),
395 ScriptInfo::new(
396 "tmpl",
397 0xA6B4,
398 (0x00, 0x3B),
399 (0x3A, 0x46),
400 (0x46, 0x67),
401 (0x68, 0x6E),
402 (0x6D, 0xFF),
403 0x5C,
404 0x20,
405 0x69,
406 ),
407 ScriptInfo::new(
408 "nightshade",
409 0x0871,
410 (0x00, 0x2B),
411 (0x2C, 0x33),
412 (0x34, 0x4E),
413 (0x4F, 0x52),
414 (0x53, 0xFF),
415 0x43,
416 0x01,
417 0x50,
418 ),
419];
420
421impl ScriptInfo {
422 pub const fn new(
423 name: &'static str,
424 version: u16,
425 uint8x2: (u8, u8),
426 uint8str: (u8, u8),
427 string: (u8, u8),
428 encstr: (u8, u8),
429 uint16x4: (u8, u8),
430 optunenc: u8,
431 deckey: u8,
432 nameopcode: u8,
433 ) -> Self {
434 ScriptInfo {
435 name,
436 version,
437 uint8x2: Section::new(uint8x2.0, uint8x2.1),
438 uint8str: Section::new(uint8str.0, uint8str.1),
439 string: Section::new(string.0, string.1),
440 encstr: Section::new(encstr.0, encstr.1),
441 uint16x4: Section::new(uint16x4.0, uint16x4.1),
442 optunenc,
443 deckey,
444 nameopcode,
445 }
446 }
447
448 pub fn query(name: &str) -> Option<&'static ScriptInfo> {
449 for info in SCRIPT_INFO.iter() {
450 if info.name == name {
451 return Some(info);
452 }
453 }
454 None
455 }
456
457 pub fn query_by_version(version: u16) -> Option<&'static ScriptInfo> {
458 for info in SCRIPT_INFO.iter() {
459 if info.version == version {
460 return Some(info);
461 }
462 }
463 None
464 }
465}